package com.sky.web.data2.menu.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sky.web.data1.user.dao.UserDao;
import com.sky.web.data1.user.entity.User;
import com.sky.web.data2.menu.dao.MenuDao;
import com.sky.web.data2.menu.entity.Menu;
import com.sky.web.data2.menu.entity.Operate;
import com.sky.web.data2.menu.service.OperateService;

@Service
public class OperateServiceImpl implements OperateService{
	@Resource
	private UserDao userdao;//data1数据源
	@Autowired
	private MenuDao menuDao;//data2数据源
	
	@Override
	@Transactional
	public void testTx(Operate operate) {
		//只为了测试，公用同一个id
		User user = new User(operate.getId(), operate.getUserName(), operate.getPwd());
		Menu menu = new Menu(operate.getId(), operate.getMenuName(), operate.getUrl());
		userdao.addUser(user);
		menuDao.addMenu(menu);
		if(user.getName().equals("wdd")){
			System.out.println(1/0);
		}
	}

}
